:HSLtoRGBConvert
{
 Parameters:
   Passed:
     0@ - Hue (float in ranges 0.0-360.0)
     1@ - Saturation (float in ranges 0.0-1.0)
     2@ - Lighting (float in ranges 0.0-1.0)
   Result:
     3@ - value of Red (byte)
     4@ - value of Green (byte)
     5@ - value of Blue (byte)

 Example:
   0AB1: call_scm_func @HSLtoRGBConvert 3 hue 0@ saturation 1@ lighting 2@ store_red_to 3@ green_to 4@ blue_to 5@ 
}
if 
    1@ == 0.0 
then
    2@ *= 255.0 
    0087: 3@ = 2@ // (float) 
    0087: 4@ = 2@ // (float) 
    0087: 5@ = 2@ // (float) 
else
    if 
        not 2@ >= 0.5 
    then
        9@ = 1.0 
        005B: 9@ += 1@ // (float) 
        0087: 7@ = 2@ // (float) 
        006B: 7@ *= 9@ // (float) 
    else
        0087: 9@ = 1@ // (float) 
        006B: 9@ *= 2@ // (float) 
        0087: 7@ = 1@ // (float) 
        005B: 7@ += 2@ // (float) 
        0063: 7@ -= 9@ // (float) 
    end
    6@ = 2.0 
    006B: 6@ *= 2@ // (float) 
    0063: 6@ -= 7@ // (float) 
    0@ /= 360.0 
    9@ = 1.0 
    9@ /= 3.0 
    0087: 8@ = 0@ // (float) 
    005B: 8@ += 9@ // (float) 
    if 
        not 8@ >= 0.0 
    then
        8@ += 1.0 
    end
    if 
        8@ > 1.0 
    then
        8@ -= 1.0
    end 
    0AB1: call_scm_func @HSLtoRGBSomeOtherCalculations 3 6@ 7@ 8@ 3@ 
    0087: 8@ = 0@ // (float) 
    if 
        not 8@ >= 0.0 
    then 
        8@ += 1.0 
    end
    if 
        8@ > 1.0
    then 
        8@ -= 1.0
    end 
    0AB1: call_scm_func @HSLtoRGBSomeOtherCalculations 3 6@ 7@ 8@ 4@ 
    9@ = 1.0 
    9@ /= 3.0 
    0087: 8@ = 0@ // (float) 
    0063: 8@ -= 9@ // (float) 
    if 
        not 8@ >= 0.0 
    then
        8@ += 1.0
    end 
    if 
        8@ > 1.0
    then 
        8@ -= 1.0 
    end
    0AB1: call_scm_func @HSLtoRGBSomeOtherCalculations 3 6@ 7@ 8@ 5@ 
end
3@ *= 255.0 
4@ *= 255.0 
5@ *= 255.0 
0092: 3@ = float 3@ to_integer 
0092: 4@ = float 4@ to_integer 
0092: 5@ = float 5@ to_integer 
0AB2: ret 3 3@ 4@ 5@ 

:HSLtoRGBSomeOtherCalculations
0087: 4@ = 2@ // (float) 
4@ *= 6.0 
if 
    not 4@ >= 1.0 
then
    0087: 4@ = 1@ // (float) 
    0063: 4@ -= 0@ // (float) 
    0087: 3@ = 4@ // (float) 
    3@ *= 6.0 
    006B: 3@ *= 2@ // (float) 
    005B: 3@ += 0@ // (float) 
else
    0087: 4@ = 2@ // (float) 
    4@ *= 2.0 
    if 
        not 4@ >= 1.0 
    then 
        0087: 3@ = 1@ // (float) 
    else
        0087: 4@ = 2@ // (float) 
        4@ *= 3.0 
        if 
            not 4@ >= 2.0 
        then
            4@ = 2.0 
            4@ /= 3.0 
            0063: 4@ -= 2@ // (float) 
            4@ *= 6.0 
            0087: 5@ = 1@ // (float) 
            0063: 5@ -= 0@ // (float) 
            006B: 5@ *= 4@ // (float) 
            0087: 3@ = 5@ // (float) 
            005B: 3@ += 0@ // (float) 
        else
            0087: 3@ = 0@ // (float)
        end
    end
end 
0AB2: ret 1 3@

:RGBtoHSVConvert
{
 Parameters:
   Passed:
     0@ - value of Red (byte)
     1@ - value of Green (byte)
     2@ - value of Blue (byte)   
   Result:
     6@ - Hue (float in ranges 0.0-1.0)
     7@ - Saturation (float in ranges 0.0-1.0)
     3@ - Value (float in ranges 0.0-1.0)

 Example:
   0AB1: call_scm_func @RGBtoHSVConvert 3 red 255 green 255 blue 255 hue_to 3@ saturation_to 4@ value_to 5@ 
}
0093: 0@ = integer 0@ to_float
0093: 1@ = integer 1@ to_float
0093: 2@ = integer 2@ to_float
0@ /= 255.0
1@ /= 255.0
2@ /= 255.0

0AB1: call_scm_func @maxFloatValues 4 number_of_values 3 value1 0@ value2 1@ value3 2@ store_result 3@
0AB1: call_scm_func @minFloatValues 4 number_of_values 3 value1 0@ value2 1@ value3 2@ store_result 4@
0087: 5@ = 3@ // (float)
0063: 5@ -= 4@  // (float)

    if
    5@ <> 0.0
    then
    0087: 7@ = 5@ // (float)
    0073: 7@ /= 3@ // (float) 
       
        if
        0045:   3@ == 0@  // (float)    ; red
        then
        0087: 6@ = 1@ // (float)
        0063: 6@ -= 2@  // (float)
        
        0073: 6@ /= 5@ // (float)
        
            if
            0025:   2@ > 1@  // (float)
            then
            6@ += 6.0            
            end
        else
            if
            0045:   3@ == 1@  // (float)    ; green
            then
            0087: 6@ = 2@ // (float)
            0063: 6@ -= 0@  // (float)
        
            0073: 6@ /= 5@ // (float)
            6@ += 2.0
            else    // blue
            0087: 6@ = 0@ // (float)
            0063: 6@ -= 1@  // (float)
        
            0073: 6@ /= 5@ // (float)
            6@ += 4.0            
            end                                      
        end
    6@ /= 6.0     
    end        
0AB2: ret 3 hue 6@ saturation 7@ value 3@

:HSVtoRGBConvert
{
 Parameters:
   Passed:
     0@ - Hue (float in ranges 0.0-1.0)
     1@ - Saturation (float in ranges 0.0-1.0)
     2@ - Value (float in ranges 0.0-1.0)      
   Result:
     8@ - value of Red (byte)
     9@ - value of Green (byte)
     10@ - value of Blue (byte)   

 Example:
   0AB1: call_scm_func @HSVtoRGBConvert 3 hue 1.0 saturation 1.0 value 1.0 red_to 4@ green_to 5@ blue_to 6@ 
}
{
f : 3@
p : 4@
q : 5@
t : 6@
}
0@ *= 6.0

0087: 3@ = 0@ // (float)
0092: 4@ = float 0@ to_integer      
0093: 4@ = integer 4@ to_float
0063: 3@ -= 4@  // (float)

4@ = 1.0
0063: 4@ -= 1@  // (float)
006B: 4@ *= 2@  // (float)

0087: 5@ = 3@ // (float)
006B: 5@ *= 1@  // (float)
5@ *= -1.0
5@ += 1.0
006B: 5@ *= 2@  // (float)

7@ = 1.0
0063: 7@ -= 3@  // (float)
006B: 7@ *= 1@  // (float)
6@ = 1.0
0063: 6@ -= 7@  // (float)
006B: 6@ *= 2@  // (float)

gosub @HSVtoRGBConvertSwitchTheRemainder

8@ *= 255.0
9@ *= 255.0
10@ *= 255.0
0092: 8@ = float 8@ to_integer
0092: 9@ = float 9@ to_integer
0092: 10@ = float 10@ to_integer
 
0AB2: ret 3 red 8@ green 9@ blue 10@

:HSVtoRGBConvertSwitchTheRemainder
0092: 0@ = float 0@ to_integer 
0A91: 7@ = 0@ / 6 // int
7@ *= 6
0062: 0@ -= 7@  // (int)

0871: init_jump_table 0@ total_jumps 6 default_jump 0 @HSVtoRGBConvertSwitchTheRemainderValue0 jumps 0 @HSVtoRGBConvertSwitchTheRemainderValue0 1 @HSVtoRGBConvertSwitchTheRemainderValue1 2 @HSVtoRGBConvertSwitchTheRemainderValue2 3 @HSVtoRGBConvertSwitchTheRemainderValue3 4 @HSVtoRGBConvertSwitchTheRemainderValue4 5 @HSVtoRGBConvertSwitchTheRemainderValue5 -1 @HSVtoRGBConvertSwitchTheRemainderValue0

:HSVtoRGBConvertSwitchTheRemainderValue0
0087: 8@ = 2@ // (float)
0087: 9@ = 6@ // (float)
0087: 10@ = 4@ // (float)
return

:HSVtoRGBConvertSwitchTheRemainderValue1
0087: 8@ = 5@ // (float)
0087: 9@ = 2@ // (float)
0087: 10@ = 4@ // (float)
return

:HSVtoRGBConvertSwitchTheRemainderValue2
0087: 8@ = 4@ // (float)
0087: 9@ = 2@ // (float)
0087: 10@ = 6@ // (float)
return

:HSVtoRGBConvertSwitchTheRemainderValue3
0087: 8@ = 4@ // (float)
0087: 9@ = 5@ // (float)
0087: 10@ = 2@ // (float)
return

:HSVtoRGBConvertSwitchTheRemainderValue4
0087: 8@ = 6@ // (float)
0087: 9@ = 4@ // (float)
0087: 10@ = 2@ // (float)
return

:HSVtoRGBConvertSwitchTheRemainderValue5
0087: 8@ = 2@ // (float)
0087: 9@ = 4@ // (float)
0087: 10@ = 5@ // (float)
return